﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_PhanQuyen : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.GetEmail();
        this.getQuyen();
    }

    protected void GetEmail()
    {
        ThanhVienBLL tvbll = new ThanhVienBLL();
        cboemail.DataTextField = "EMAIL";
        cboemail.DataValueField = "EMAIL";
        //cbomadm.DataMember = "MADM";
        cboemail.DataSource = tvbll.getEmail();
        cboemail.DataBind();
        if(cboemail.Items.Count==0)
            lblkq.Text = "Không còn member để phân quyền!";
    }

    protected void getQuyen()
    {
        QuyenBLL quyenbll = new QuyenBLL();
        cboquyen.DataTextField = "TENQUYEN";
        cboquyen.DataValueField = "MAQUYEN";
        //cbomadm.DataMember = "MADM";
        cboquyen.DataSource = quyenbll.getAllQuyen();
        cboquyen.DataBind();
    }
    protected void btxacnhan_Click(object sender, EventArgs e)
    {
        string mail=cboemail.Text;
        int quyen=int.Parse(cboquyen.SelectedValue);
        ThanhVienBLL tvbll = new ThanhVienBLL();
        bool kq=tvbll.updateQuyen(mail, quyen);
        if (kq)
        {
            lblkq.Text = "Phân quyền thành công!";
        }
        else

            lblkq.Text = "Phân quyền thất bại!";
    }
}